package mo.leetcode_top;

public class L122 {

    public int maxProfit(int[] prices) {
        int res = 0;
        for (int i = 1; i <= prices.length-1; i++) {
            if (prices[i] > prices[i-1]) {
                res += prices[i] - prices[i-1];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        L122 test = new L122();
        System.out.println(test.maxProfit(new int[]{7,1,5,3,6,4}));
    }

}
